package _021_10_3

import "math"

func maxSubArray(nums []int) int {
	n := len(nums)
	maxNum := float64(nums[0])
	temp := float64(0)
	//for j := 0; j < n; j++ {
	//	temp = 0
	for i := 0; i < n; i++ {
		temp += float64(nums[i])
		maxNum = math.Max(maxNum, temp)
	}
	//}

	return int(maxNum)
}
